/*
 * Copyright (c) 2009-2022 Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the License); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __ARM_2D_SCENE_WATCH_H__
#define __ARM_2D_SCENE_WATCH_H__

/*============================ INCLUDES ======================================*/

#include "arm_2d.h"

#include "arm_2d_helper_scene.h"

#ifdef   __cplusplus
extern "C" {
#endif

#if defined(__clang__)
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wunknown-warning-option"
#   pragma clang diagnostic ignored "-Wreserved-identifier"
#   pragma clang diagnostic ignored "-Wmissing-declarations"
#   pragma clang diagnostic ignored "-Wpadded"
#elif __IS_COMPILER_ARM_COMPILER_5__
#elif __IS_COMPILER_GCC__
#   pragma GCC diagnostic push
#   pragma GCC diagnostic ignored "-Wformat="
#   pragma GCC diagnostic ignored "-Wpedantic"
#   pragma GCC diagnostic ignored "-Wpadded"
#endif

/*============================ MACROS ========================================*/

/* OOC header, please DO NOT modify  */
#ifdef __USER_SCENE_WATCH_IMPLEMENT__
#   undef __USER_SCENE_WATCH_IMPLEMENT__
#   define __ARM_2D_IMPL__
#endif
#include "arm_2d_utils.h"

/*============================ MACROFIED FUNCTIONS ===========================*/

/*!
 * \brief initalize scene_watch and add it to a user specified scene player
 * \param[in] __DISP_ADAPTER_PTR the target display adapter (i.e. scene player)
 * \param[in] ... this is an optional parameter. When it is NULL, a new 
 *            user_scene_watch_t will be allocated from HEAP and freed on
 *            the deposing event. When it is non-NULL, the life-cycle is managed
 *            by user.
 * \return user_scene_watch_t* the user_scene_watch_t instance
 */
#define arm_2d_scene_watch_init(__DISP_ADAPTER_PTR, ...)                    \
            __arm_2d_scene_watch_init((__DISP_ADAPTER_PTR), (NULL, ##__VA_ARGS__))

/*============================ TYPES =========================================*/
/*!
 * \brief a user class for scene watch
 */
typedef struct user_scene_watch_t user_scene_watch_t;


typedef enum{

    APPLE       = 0,
    BOOM        = 1,
    BANANA      = 2,
    WATERMELON  = 3
    
};

typedef enum{

    UP       = 0,
    DOWN        = 1,
};


#define GRAVITY    1  //重力 
#define NUM_FRUITS 4   //水果的种类数量
#define MAX_NUM_FRUITS 4   //屏幕最大出现的水果数量
#define CUT_THRESHOLD 40   // 切水果刀的阈值

typedef struct {
        int iX1, iY1; // 刀的起点
        int iX2, iY2; // 刀的终点
        int active;  // 刀的活动状态
} Knife_t;

struct user_scene_watch_t {
    implement(arm_2d_scene_t);                                                  //! derived from class: arm_2d_scene_t

ARM_PRIVATE(
    /* place your private member here, following two are examples */
    int64_t lTimestamp[4];
    bool bUserAllocated;

    struct {
        arm_2d_op_fill_cl_msk_opa_trans_t   tOP;
        arm_2d_helper_transform_t           tHelper;
    }Pointers[3];

    

    struct {
        arm_2d_helper_dirty_region_item_t   tDirty_Region_item;
        arm_2d_region_t     region;

        uint16_t Limit_X_POS;
        uint16_t Limit_Y_POS;
        uint8_t Dir;

        float initialVx;  //初始Vx
        float initialVy;  //初始Vy

        int initialX;  // 用于存储水果生成时的初始 X 位置
        int initialY;  // 用于存储水果生成时的初始 Y 位置


        float Time;//根据起始和结束坐标以及重力加速度计算从起始到结束的时间。
        float decrement_per_time_unit;//计算每次递减的值（decrement_per_time_unit），初始速度除以时间

        float vx;  //水平速度
        float vy;  //垂直速度
        float Angle; //初始角度

        float angularSpeed; //角速度
        bool active; 
        //int speed;



        arm_2d_region_t     left_region;
        float left_vx;  //水平速度
        float left_vy;  //垂直速度
        float left_Angle; //初始角度

      




        arm_2d_region_t     right_region;
        float right_vx;  //水平速度
        float right_vy;  //垂直速度
        float right_Angle; //初始角度

        bool cut;
     

        arm_2d_location_t pivot_Center;  //旋转中心

        arm_2d_tile_t SrcSource;
        arm_2d_tile_t Left_SrcSource;
        arm_2d_tile_t Right_SrcSource;


		arm_2d_op_trans_msk_opa_t    tOP;
        arm_2d_helper_dirty_region_transform_t tHelper;

        
		arm_2d_op_trans_msk_opa_t    tOP_Left;
        arm_2d_helper_dirty_region_transform_t tHelper_Left;

        
		arm_2d_op_trans_msk_opa_t    tOP_Right;
        arm_2d_helper_dirty_region_transform_t tHelper_Right;
    }Fruit[NUM_FRUITS];

    Knife_t Knife; 

)
    /* place your public member here */
    
};

/*============================ GLOBAL VARIABLES ==============================*/
/*============================ PROTOTYPES ====================================*/

ARM_NONNULL(1)
extern
user_scene_watch_t *__arm_2d_scene_watch_init(   arm_2d_scene_player_t *ptDispAdapter, 
                                        user_scene_watch_t *ptScene);

#if defined(__clang__)
#   pragma clang diagnostic pop
#elif __IS_COMPILER_GCC__
#   pragma GCC diagnostic pop
#endif

#ifdef   __cplusplus
}
#endif

#endif

